﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iESELibrary.DESCrypto.Vault
{
	public class RegKey
	{
		#region Variables
		private bool disposed = false;
		private string name;
		private string value;
		private string relativePath;
		private StringBuilder keyClass;
		private uint keyClassSize;
		private byte[] data;
		#endregion

		#region Properties
		public string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				this.name = value;
			}
		}

		public string Value
		{
			get
			{
				return this.value;
			}
			set
			{
				this.value = value;
			}
		}

		public string RelativePath
		{
			get
			{
				return this.relativePath;
			}
			set
			{
				this.relativePath = value;
			}
		}

		public byte[] Data
		{
			get
			{
				return this.data;
			}
			set
			{
				this.data = value;
			}
		}

		public StringBuilder KeyClass
		{
			get
			{
				return this.keyClass;
			}
			set
			{
				this.keyClass = value;
			}
		}

		public uint KeyClassSize
		{
			get
			{
				return this.keyClassSize;
			}
			set
			{
				this.keyClassSize = value;
			}
		}
		#endregion

		#region Public Methods
		public byte[] GetByteClass()
		{
			return Enumerable.Range(0, this.keyClass.Length)
					 .Where(hex => hex % 2 == 0)
					 .Select(hex => Convert.ToByte(this.keyClass.ToString().Substring(hex, 2), 16))
					 .ToArray();
		}
		#endregion

		#region Constructors
		public RegKey(string name, string relativePath, string value)
		{
			this.name = name;
			this.relativePath = relativePath;
			this.value = value;
		}
		#endregion
	}
}
